package com.dlc.felear.xiaoensale.activity;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import com.dlc.felear.xiaoensale.R;
import com.dlc.felear.xiaoensale.adapter.ActionItemStepAdapter;
import com.dlc.felear.xiaoensale.constant.Constant;
import com.dlc.felear.xiaoensale.deviceUtil.TopbarHelper;
import com.dlc.felear.xiaoensale.entity.ActionStepItem;
import com.itdlc.android.library.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 保养选择面板
 */
public class MotorPagerActivity extends BaseActivity  {
    private static final String TAG = "MotorPagerActivity";
    private TopbarHelper topbarHelper;
    private static final String GLSCSJ = "控制板";
    private static final String CPBDICK = "锅体伺服电机";
    private static final String CPUPD = "翻料盒伺服电机";
    private static final String CKCCJL = "搅拌伺服电机";
    private static final String SBCSSZ = "设备参数设置";
    @BindView(R.id.cp_gv1)
    GridView gridView;
    private ActionItemStepAdapter actionitemstepadapter;


    @Override
    protected int getLayoutRes() {
        return R.layout.activity_maintain_page;
    }

    @Override
    protected void initialView() {
        topbarHelper = new TopbarHelper(this);
        topbarHelper.setTitle("设备保养页面");
        topbarHelper.setcon(R.drawable.arrow_left);
        topbarHelper.setNavActivity(ParamerSettingActivity.class);
        actionitemstepadapter = new ActionItemStepAdapter(this);
        gridView.setAdapter(actionitemstepadapter);
        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                handleAction(actionitemstepadapter.getItem(position).getName());
            }
        });
    }

    private void handleAction(String name) {
        switch (name) {
            case GLSCSJ:
                startActivity(new Intent(this, MainTainPageNewActivity.class));
                break;
            case CPBDICK:
                Intent intent1=new Intent(this,NormalMotorDebugActivity.class);
                startActivity(intent1);
                break;
            case CPUPD:
                Intent intent2=new Intent(this,SfMotorSettingActivity.class);
                intent2.putExtra(SfMotorSettingActivity.ADDR,1);
                startActivity(intent2);
                break;
            case CKCCJL:
                startActivity(new Intent(this, SfMotorDebugActivity.class));
                break;
            case SBCSSZ:
                startActivity(new Intent(this,DeviceParamersSettingActivity.class));
                break;
        }
    }




    @Override
    protected void initData() {
        actionitemstepadapter.setItems(getActionStepItemData5());
    }


    public static List<ActionStepItem> getActionStepItemData5(){
        List<ActionStepItem> list=new ArrayList<>();
        list.add(new ActionStepItem(Constant.ACTION_STEP_JGT,GLSCSJ, R.drawable.setting_1_icon,0));
        list.add(new ActionStepItem(Constant.ACTION_STEP_JGT,CPBDICK, R.drawable.setting_1_icon,0));
//        list.add(new ActionStepItem(Constant.ACTION_STEP_JGT,CPUPD, R.drawable.setting_1_icon,0));
//        list.add(new ActionStepItem(Constant.ACTION_STEP_JGT,CKCCJL, R.drawable.setting_1_icon,0));
        list.add(new ActionStepItem(Constant.ACTION_STEP_JGT,SBCSSZ, R.drawable.setting_1_icon,0));
        return list;
    }



}